/**
 字节字符转换流
 Reader 基类 = InputStreamReader  转换流  
 
 Writer 基类 = OutputStreamWriter 转换流
 过程是：
   读：	文件  --> InputStream  (字节)  --> InputStreamReader  (字符)  --> 程序
   写： 文件  <--  OutputStream (字节)  <-- OutputStreamWriter  (字符) <-- 程序	
 */

/*
package com.leo.第八章_文件与IO;
import java.io.Reader;
import java.nio.charset.Charset;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
public class U8_L5_字节字符转换流 {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
			run();
			
		
	}
	private static void run() {
		
		File f=new File("E:\\eclipse-workspace\\test\\RW");
		if(!f.exists()) {
			f.mkdir();
		}
		if(f.getAbsolutePath()!="E:\\eclipse-workspace\\test\\RW\\rw.txt") {
			f=new File("E:\\eclipse-workspace\\test\\RW\\rw.txt");
			try {
				f.createNewFile();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		try {
			OutputStream out=new FileOutputStream("E:\\eclipse-workspace\\test\\RW\\rw.txt",true);
			InputStream in=new FileInputStream("E:\\eclipse-workspace\\test\\RW\\rw.txt");
			System.out.println("字节输入输出准备完毕...");
			Write(out,f);
			Read(in,f);
		} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	private static void Read(InputStream in,File f) {
		Reader reader=new InputStreamReader(in,Charset.defaultCharset());
		char[] cs=new char[1024];
		int len=-1;
		try {
			System.out.println("开始读取，路径: "+f.getAbsolutePath()+"\n");
			while((len=reader.read(cs))!=-1) {
				System.out.println(new String(cs,0,len));	
			}
			reader.close();
			System.out.println("读取结束。路径:"+f.getAbsolutePath());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private static void Write(OutputStream out,File f) {
		Writer writer=new OutputStreamWriter(out,Charset.defaultCharset());
		try {
			writer.write("this is a 句子 0。\r\n");
			writer.close();
			System.out.println("写入完毕.路径: "+f.getAbsolutePath());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
*/